# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=gitui
pkgver=0.25.2
pkgrel=0
pkgdesc="Blazing fast terminal client for git"
url="https://github.com/extrawurst/gitui"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="MIT"
makedepends="
	cargo
	cargo-auditable
	libgit2-dev
	oniguruma-dev
	openssl-dev
	zlib-dev
	"
source="https://github.com/extrawurst/gitui/archive/v$pkgver/gitui-$pkgver.tar.gz"
options="net"

export LIBSSH2_SYS_USE_PKG_CONFIG=1  # use system libssh2
export RUSTONIG_DYNAMIC_LIBONIG=1  # use system libonig

_cargo_opts="--frozen --no-default-features --features regex-onig"

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config <<-EOF

		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
	EOF

	# open64
	cargo update -p getrandom --precise 0.2.10

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build $_cargo_opts --release
}

check() {
	cargo test $_cargo_opts
}

package() {
	install -D -m755 target/release/gitui "$pkgdir"/usr/bin/gitui
}

sha512sums="
59b08e8cc164ea74ed7a52f5517de7fe1a03e1a02b802adca1c7b77a6cbd1a6c1fe3b7135f6af6c649bb3b040bd0e8a57f7426c8c637232127e19b7b07eb195a  gitui-0.25.2.tar.gz
"
